﻿# CMakeList.txt: 顶层 CMake 项目文件，在此处执行全局配置
# 并包含子项目。
#
cmake_minimum_required (VERSION 3.8)

project("mapdis")
SET(EXE_NAME "mapdis")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BIN_PATH})



SET(IMGUI_PATH "J:/openLib/imgui")
SET(IMGUI_FILEDIALOG_PATH "J:/openLib/ImGuiFileDialog")
include_directories(
    "${CMAKE_CURRENT_SOURCE_DIR}/tools"
	"${IMGUI_PATH}"
	"${IMGUI_PATH}/backends"
    "${IMGUI_FILEDIALOG_PATH}"
    "./src"
)

file(GLOB_RECURSE IMGUI_FILES 
"${IMGUI_PATH}/imconfig.h" 
"${IMGUI_PATH}/imgui.h"
"${IMGUI_PATH}/imgui.cpp"
"${IMGUI_PATH}/imgui_internal.h"
"${IMGUI_PATH}/imgui_draw.cpp"
"${IMGUI_PATH}/imgui_tables.cpp"
"${IMGUI_PATH}/imgui_widgets.cpp"
"${IMGUI_PATH}/backends/imgui_impl_win32.*"
"${IMGUI_PATH}/backends/imgui_impl_dx12.*"
)

file(GLOB_RECURSE IMGUI_FILEDIALOG_FILES
"${IMGUI_FILEDIALOG_PATH}/ImGuiFileDialog.h"
"${IMGUI_FILEDIALOG_PATH}/ImGuiFileDialogConfig.h"
)

file(GLOB_RECURSE MAPDIS_SRC_FILES
"./src/*"
)

source_group("third" FILES ${IMGUI_FILES} ${IMGUI_FILEDIALOG_FILES})
source_group("tools" FILES ${TOOLS_INC_LIST})
source_group("main" FILES main.cpp)
source_group("src" FILES ${MAPDIS_SRC_FILES})

add_definitions(-DImTextureID=ImU64 -D_UNICODE -DUNICODE -DAS_RAND)

find_package(sdl2 REQUIRED)
find_package(ffmpeg REQUIRED)
set(THIRD_INCLUDE_DIRS
${FFMPEG_INCLUDE_DIRS}
)

#message("ffmpeg lib:${FFMPEG_LIBRARIES}")
set(THIRD_LIBRARY_DIRS 
${FFMPEG_LIBRARIES}
)


set(THIRD_LINK_LIBRARY
${FFMPEG_LIBRARIES}
$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
$<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>
d3d12
d3dcompiler
dxgi
ImGuiFileDialog
)
message("third link lib:${THIRD_LINK_LIBRARY}")

build_project(
	NAME 
		${EXE_NAME} 
	SRCS
		"main.cpp"
		${TOOLS_INC_LIST} ${IMGUI_FILES} ${MAPDIS_SRC_FILES} ${IMGUI_FILEDIALOG_FILES}
	INC_DIR
		${THIRD_INCLUDE_DIRS}
	LIB_DIR
		${THIRD_LIBRARY_DIRS}
	LINK_LIB
		${THIRD_LINK_LIBRARY}
		#hiredis::hiredis
)

# add_executable(${EXE_NAME} main.cpp ${TOOLS_INC_LIST} ${IMGUI_FILES} ${MAPDIS_SRC_FILES} ${IMGUI_FILEDIALOG_FILES})

# target_compile_options(${EXE_NAME} PRIVATE /source-charset:utf-8 /execution-charset:utf-8)

# target_include_directories(${EXE_NAME} PRIVATE ${THIRD_INCLUDE_DIRS})

# target_link_directories(${EXE_NAME} PRIVATE ${THIRD_LIBRARY_DIRS})

# target_link_libraries(${EXE_NAME} PRIVATE
#     DbgHelp
#     d3d12
#     d3dcompiler
#     dxgi
#     as_tools
#     ImGuiFileDialog
#     ${THIRD_LINK_LIBRARY}
# )

#set_property(TARGET ${EXE_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BIN_PATH}/bin")

